#ifndef IMAGEDOWNLOADER_H
#define IMAGEDOWNLOADER_H

#include <QObject>
#include <QUrl>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QImage>
#include <QByteArray>
#include <QFileInfo>
#include <QDir>
#include <QSettings>
#include <QHash>

class ImageDownloader : public QObject
{
	Q_OBJECT

public:
	ImageDownloader(QObject *parent = 0);
	void downloadImages(const QList<QUrl> &urls);
	QHash<QString, QImage> getImages() const;

signals:
	void finished();

public slots:
	void downloadFinished(QNetworkReply *reply);

private:
	QNetworkAccessManager m_manager;
	QString homeAppImagesPath;		//on Windows: c:/documents and settings/username/Application Data/
	QHash<QString, QImage> m_images;
	int downloadCount;

	QString decodeUrlToFilename(const QUrl &url);
	void resolveHomeAppPath();
};

#endif // IMAGEDOWNLOADER_H